package flown.window.graphics.ui;


import flown.window.graphics.Renderer2D;


/**
 * @author flown
 */

public class Button extends Widget
{
    private Label label;

    public Button(String text) { this(text, 0, 0, 0, 0); }
    public Button(String text, int x, int y)
    {
        this(text, x, y, 0, 0);
    }
    public Button(String text, int x, int y, int width, int height)
    {
        super(x, y, width, height);
        label = new Label(text, x, y + height, width, height);
    }

    @Override public final void AddInContainer(Container c)
    {
        super.AddInContainer(c);
        this.label.at = c;
    }
    @Override public final void SetBounds(int x, int y, int width, int height)
    {
        super.SetBounds(x, y, width, height);
        if (this.label != null)
            this.label.SetBounds(x, y + height, width, height);
    }
    @Override public final void Render(Renderer2D renderer)
    {
        renderer.DrawRect(this.rect.x, this.rect.y, this.rect.width, this.rect.height);
        this.label.Render(renderer);
    }

    public final void SetText(String text) {this.label.text = text;}
    public final String GetText() {return this.label.text;}


    public void SetClickEvent()
    {

    }

}


